< previous page page_577 next page >

Page 577
The Windows Directory Information
Information for the Windows directory, the Windows\System directory, and the temporary directory is retrieved via the GetWindowsDirectory(), GetWindowsSystemDirectory(), and GetTempPath() API calls, respectively. A method named WinDirInfo() is created to retrieve this information and fill in the properties of the system information class. Heres the code:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub WinDirInfo()
   Dim strBuffer As String
   Dim lngLen As Long

   If mstrWinDir = "" Then
      ' Get the path information (windows, system, and temp).
      strBuffer = Space(MAX_PATH)
      lngLen = GetWindowsDirectory(strBuffer, MAX_PATH)
      mstrWinDir = Left(strBuffer, lngLen)

      strBuffer = Space(MAX_PATH)
      lngLen = GetSystemDirectory(strBuffer, MAX_PATH)
      mstrWinSysDir = Left(strBuffer, lngLen)

      strBuffer = Space(MAX_PATH)
      lngLen = GetTempPath(MAX_PATH, strBuffer)
      mstrWinTempDir = Left(strBuffer, lngLen)
   End If
End Sub
Summary
In this chapter, you learned how to use the Declare statement to tell Visual Basic that youll be using a function contained in an external DLL. Using the Windows API, you can perform many tricks with list boxes and combo boxes. You can also retrieve system information about your operating system. These Windows API functions are very powerful and can make your applications do many things that you would normally have to buy third-party tools for. This alone can be worth the investment of your time in understanding and using these Windows API calls.

 
< previous page page_577 next page >

If you like this book, buy it!